package commons.drawing;

import commons.drawing.I_Drawable;
import commons.ihm.ParametresAffichageCarto;
import commons.utils.UtilsGeom;
import commons.utils.primitive_geom.Point_d;
import commons.utils.primitive_geom.Rect_d;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

public class RectDrawable extends Rect_d implements I_Drawable {

	private Color borderColor, fillColor;

	public RectDrawable(Rect_d r, Color borderColor, Color fillColor) {
		super(r);
		this.borderColor = borderColor;
		this.fillColor = fillColor;
	}


	public void draw(Graphics2D g, ParametresAffichageCarto pac) {
		
		g.setStroke(pac.getBasicStroke1());

		Rectangle2D.Float shRect = new Rectangle2D.Float();
		shRect.x = pac.x2X(getXMin());
		shRect.y = pac.y2Y(getYMax());
		shRect.width = pac.lg2LG(getWidth());
		shRect.height = pac.lg2LG(getHeight());

		if (fillColor != null) {
			g.setColor(fillColor);
			g.fill(shRect);
		}
		if (borderColor != null) {
			g.setColor(borderColor);
			g.draw(shRect);
		}
	}

	public double distTo(Point_d pt) {
		return UtilsGeom.getDistRectPoint(this, pt.x, pt.y);
	}

	public String getInfoBulle() {
		return "";
	}

	public String getInfoDetaillee() {
		return "";
	}

}
